import { createApp } from 'vue'
import router from './router';
import './assets/js/resize';
import './assets/style/rest.css';
import 'vant/lib/index.css';
import 'vant/es/toast/style';
import vant from 'vant';
import App from './App.vue'

const app = createApp(App);

let vueHistoryPagePath = [];
router.beforeEach((to, from, next) => {
    document.title = to.meta.title;
    if (vueHistoryPagePath[vueHistoryPagePath.length - 2] === to.fullPath) { // 如果是上一页，可能是返回，也可能是跳转上一页，统一做返回处理
        vueHistoryPagePath.splice(vueHistoryPagePath.length - 1, 1); // 删除最后一项
    } else {
        vueHistoryPagePath.push(to.fullPath);
    }
    console.log('vueHistoryPagePath', vueHistoryPagePath);
    next();
});

// 配置全局变量 页面中使用 inject 接收
app.provide('global', {
    vueHistoryPagePath
})

app.use(router, vant).mount('#app');
